<template>
    <div>

      <el-card class="box-card" style="width: 30%;margin-left: 35%;margin-top: 12%;height:250px;padding-top: 4%">

        <el-form :model="ruleForm" status-icon label-width="100px" class="demo-ruleForm">

          <el-form-item label="用户名称" prop="userName">
            <el-input v-model.number="ruleForm.userName"></el-input>
          </el-form-item>
          <el-form-item label="登录密码" prop="password">
            <el-input type="password" v-model="ruleForm.password" autocomplete="off"></el-input>
          </el-form-item>

          <el-form-item style="margin-right: 110px">
            <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
            <el-button >重置</el-button>
          </el-form-item>
        </el-form>

      </el-card>

    </div>
</template>

<script>
    export default {
        name: "login",
        data(){
          return{
            ruleForm:{
               userName:undefined,
               password:undefined,
            }
          }
        },
        methods:{
          submitForm(ref){

              //调用登录的接口
              this.$axios.post(this.$myInfo.loginPath+"login/toLogin",this.ruleForm).then((reponse)=>{
                   if(reponse.data.code==200){
                      let userInfo=reponse.data.result;
                      //存一下全局的数据
                      //this.$store.state.umsg=userInfo;
                      sessionStorage.setItem("state",JSON.stringify(userInfo))

                      //跳转到首页
                      this.$router.push({path:"/index"})
                   }

              })

          }
        }
    }
</script>

<style scoped>

</style>
